<template>
  <div class="md">
    <div class="md-title">
      <div class="mdt-left">我的门店</div>
      <div class="mdt-right">
        <button>切换门店</button>
      </div>
    </div>
    <div class="md-img">
      <img :src="mPic" alt="" />
    </div>
    <div class="md-main" @click="getMd">
      <div class="md-tit">
        <img class="md-icon" src="../assets/BinMd-img/md-icon.png" alt="" />
        <p>{{ tname }}</p>
      </div>
      <div class="u-span">
        <span>{{ openTime }} {{ trainingType }}</span> <img src="../assets/BinMd-img/payType.png" alt="" />
      </div>
      <div class="d-span clearfix">
        <span>{{ `面积${mArea}㎡` }}</span
        ><span>{{ `操房${trainingRoom}个` }}</span>
      </div>
      <img class="turnR" src="../assets/BinMd-img/turnR.png" alt="" />
    </div>
    <hr class="hr" />
    <div class="md-footer">
      <div class="mdf-left">
        <img class="local" src="../assets/BinMd-img/locaIcon.png" alt="" />
        <div class="add-text">
          <span>{{ madress }}</span
          ><br />
          <span class="md-distance">{{ `距我${distance}km` }}</span>
        </div>
      </div>
      <div class="vx">
        <img src="../assets/BinMd-img/vx.png" alt="" />
        <p>微信</p>
      </div>
      <div class="vx" @click="pShow">
        <img src="../assets/BinMd-img/phone.png" alt="" />
        <p>电话</p>
      </div>
    </div>
    <div class="phone" v-show="phoTog">
      <p>{{ mPhone }}</p>
      <p>呼叫</p>
      <button @click="pDis">取消</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Shop',
  data() {
    return {}
  },
  async created() {
    let obj = await this.getCoordinate()
    console.log(obj)
    const { data: res } = await this.$http.post('./v1/md/getcoo', qs.stringify(obj))
    console.log(res)
  },
  mounted() {},
  methods: {
    getCoordinate() {
      let obj = {}
      return new Promise(resolve => {
        let g = window.navigator.geolocation
        g.getCurrentPosition(
          res => {
            ;(obj.lat = res.coords.latitude), (obj.lng = res.coords.longitude)
            resolve(obj)
          },
          err => {
            console.log(err)
            obj.lat = 15
            obj.lng = 22
            resolve(obj)
          },
          { timeout: 10000 }
        )
      })
    }
  }
}
</script>

<style lang="less" scoped>
.md-title {
  background-color: #f5f5f5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0px 12px;
  .mdt-left {
    font-size: 22px;
    color: #444444;
  }
  .mdt-right {
    color: #666666;
    > button {
      border-radius: 20px;
      border-color: #666666;
      border-style: solid;
      border-width: 1px;
      font-size: 10px;
      padding: 2px 13px 2px 13px;
    }
  }
}

.hr {
  width: 92%;
  margin: 0 auto;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
.md {
  // border-radius: 5px;
  // width: 100%;
  // margin:  auto;
  margin: 14px auto;
  width: 344px;
  border-radius: 10px;
  background-color: #fff;
  .md-img {
    width: 100%;
    height: 120px;
    img {
      border-radius: 5px 5px 0 0;
      object-fit: cover;
      object-position: 0 -45px;
      width: 100%;
      height: 100%;
    }
  }
  .md-main {
    position: relative;
    // border-bottom: rgba(128, 128, 128, 0.144) 1px solid;
    margin: -10px 5px 0px;
    .turnR {
      position: absolute;
      right: 10px;
      top: 70px;
      width: 12px;
      height: 12px;
    }
    .md-tit {
      .md-icon {
        position: relative;
        height: 50px;
        width: 50px;
        border-radius: 5px;
        margin: 0 10px;
      }
      p {
        display: inline-block;
        vertical-align: top;
      }
      width: 100%;
      font-size: 20px;
    }
    .u-span {
      margin: -5px 0 0 6px;
      font-size: 14px;
      img {
        height: 16px;
        vertical-align: text-top;
      }
    }
    .d-span {
      margin: 10px 0 10px;
      font-size: 12px;
      color: grey;
      margin-left: 6px;
      span {
        transform: scale(0.9);
        float: left;
        background-color: rgba(233, 230, 230, 0.459);
        padding: 2px 6px;
      }
    }
  }

  .md-footer {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 0 auto;
    font-size: 14px;
    padding: 16px 0;
    .mdf-left {
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .add-text {
      padding-left: 10px;
      font-size: 12px;
    }
    .local {
      height: 18px;
    }
    .md-distance {
      color: grey;
    }
    .vx {
      img {
        width: 25px;
      }
      p {
        margin: 0;
        font-size: 12px;
      }
    }
  }
}
.clearfix::after {
  content: '';
  display: table;
  clear: both;
}
.phone {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
  width: 260px;
  height: 130px;
  padding: 20px;
  z-index: 30;
  color: rgb(76, 221, 76);
  border: rgba(0, 0, 0, 0.473) 1px solid;
  border-radius: 5px;
  background-color: white;
  font-size: 16px;
  text-align: center;
  p {
    border-bottom: rgba(128, 128, 128, 0.192) 1px solid;
    margin: 0;
    line-height: 40px;
  }
  button {
    //  display: block;
    width: 100px;
    border: 0;
    margin-top: 15px;
    line-height: 30px;
  }
}
</style>

<script>
import mPic from '../assets/BinMd-img/md0.jpg'

export default {
  name: 'BinMd',
  data() {
    return {
      tname: '龙华大唐时代店',
      openTime: '营业中 7*24h',
      trainingType: '自助健身',
      mArea: 400,
      trainingRoom: 1,
      madress: '梅龙大道清龙站大唐时代b座',
      distance: 6.6,
      mPic,
      mPhone: '18123900084',
      phoTog: 0
    }
  },
  methods: {
    pShow() {
      this.phoTog = 1
    },
    pDis() {
      this.phoTog = 0
    },
    async getMd() {
      const { data: res } = this.$http.get('./v1/md/1', { params: { mid: 1 } })
      console.log(res)
    }
  }
}
</script>
